var oldObjArrayDeposits = new Array();
var setoldObjArrayDeposits = new Array();
//////////////Start BookingDeposits Page////////////////
function searchAllbookingdepositsPage(value,e){
	if (e.keyCode == 13 && !e.ctrlKey) {
		getReservationRoomBookingDepositsManageMent("textSearch",value)
		$("#SearchAll_bookingdepositsPage").val("");
	}
}
function getReservationRoomBookingDepositsManageMent(data,valueSearch){
	clearData();
	waitingDialog({});
	var searchName = $("#SearchAll_deposits").val();
	if($("#RowpagerBookingDepositsListRoomManageMent").val() == null){
		getCurrentTabData().lineDeposits = 10;
	}else{
		getCurrentTabData().lineDeposits = $("#RowpagerBookingDepositsListRoomManageMent").val();
	}
	if($("#pagerBookingDepositsListRoomManageMent").val() == null){
		var pagePointer = 1; 
	}else{
		if(valueSearch!=""&&valueSearch!=undefined){
			var pagePointer = valueSearch; 
		}else{
			var pagePointer = 1;
			getCurrentTabData().pagerNumber = 1;
		}
		//var pagePointer = $("#pagerBookingDepositsListRoomManageMent").val(); 
	}
	var offfset = (getCurrentTabData().lineDeposits*pagePointer)-getCurrentTabData().lineDeposits;
	var dataOld =  $("#typeCheckReservationDeposits").val();
	var valueDateCheckin = $("#calendar_btw_checkinDeposits").attr("dateofBtwCheckinDeposits");
	var valueDateCheckout = $("#calendar_btw_checkoutDeposits").attr("dateofBtwCheckoutDeposits");
	if(valueDateCheckin!=""&&valueDateCheckout!=""){
		var dateCheckin = $("#calendar_btw_checkinDeposits").attr("dateofBtwCheckinDeposits");
	  	var dateCheckout = $("#calendar_btw_checkoutDeposits").attr("dateofBtwCheckoutDeposits");
	  	$("#calendar_btw_checkinDeposits").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutDeposits").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinDeposits').attr('dateofBtwCheckinDeposits',dateCheckin);
		$('#calendar_btw_checkoutDeposits').attr('dateofBtwCheckoutDeposits',dateCheckout);
		getCurrentTabData().valueDateCheckin = dateCheckin;
		getCurrentTabData().valueDateCheckout = dateCheckout;
	}else{
		/*var dateCheckin = new Date().toSystemFormat();
		var dateCheckout= new Date().toSystemFormat();
		$("#calendar_btw_checkinDeposits").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutDeposits").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinDeposits').attr('dateofBtwCheckinDeposits',dateCheckin);
		$('#calendar_btw_checkoutDeposits').attr('dateofBtwCheckoutDeposits',dateCheckout);
		getCurrentTabData().valueDateCheckin = dateCheckin;
		getCurrentTabData().valueDateCheckout = dateCheckout;*/
	}
	if(data=="BookingDepositsListRoomManageMent"){
		typeReservationDepositsFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="G"){
		getCurrentTabData().typeReservationDeposits = data;
		typeReservationDepositsFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="S"){
		getCurrentTabData().typeReservationDeposits = data;
		typeReservationDepositsFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="A"){
		getCurrentTabData().typeReservationDeposits = data;
		typeReservationDepositsFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data == "textSearch"){
		showDataResRoomBookingDepositsManageMent(data,"textSearch");
	}else if(data == "dateSearch"){
		var dataOld =  $("#typeCheckReservationDeposits").val();
		var valueDateCheckin = $("#calendar_btw_checkinDeposits").attr("dateofBtwCheckinDeposits");
		var valueDateCheckout = $("#calendar_btw_checkoutDeposits").attr("dateofBtwCheckoutDeposits");
		if(valueDateCheckin!=""&&valueDateCheckout!=""){
			var dateCheckin = $("#calendar_btw_checkinDeposits").attr("dateofBtwCheckinDeposits");
			getCurrentTabData().valueDateCheckin = valueDateCheckin;
			getCurrentTabData().valueDateCheckout = valueDateCheckout;
			var dateCheckout= $("#calendar_btw_checkoutDeposits").attr("dateofBtwCheckoutDeposits");
			if(dataOld=="G"){
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationBookingDepositsGroup&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationBookingDepositsGroup&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
				}else{
					getCurrentTabData().beforePageDeposits = ""; 
					getCurrentTabData().beforeSubPageDeposits = "";
					var link = "/reservationService?func=getReservationBookingDepositsGroup&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
				}
			}else if(dataOld=="S"){
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationBookingDepositsSingle&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationBookingDepositsSingle&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
				}else{
					getCurrentTabData().beforePageDeposits = ""; 
					getCurrentTabData().beforeSubPageDeposits = "";
					var link = "/reservationService?func=getReservationBookingDepositsSingle&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
				}
			}else if(dataOld=="A"){
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationBookingDeposits&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationBookingDeposits&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
				}else{
					getCurrentTabData().beforePageDeposits = ""; 
					getCurrentTabData().beforeSubPageDeposits = "";
					var link = "/reservationService?func=getReservationBookingDeposits&offset="
						+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
				}
			}
		}else{
			$("#calendar_btw_checkinDeposits").select();
			closeWaitingDialog();
		}
	}
}
function showDataResRoomBookingDepositsManageMent(data,output){
	var valueDateCheckin = getCurrentTabData().valueDateCheckin;
	var valueDateCheckout = getCurrentTabData().valueDateCheckout;
	if((valueDateCheckin!=""&&valueDateCheckout!="")&&(valueDateCheckin!=undefined&&valueDateCheckout!=undefined)){
		var dateCheckin = valueDateCheckin;
	  	var dateCheckout = valueDateCheckout;
	  	$("#calendar_btw_checkinDeposits").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutDeposits").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinDeposits').attr('dateofBtwCheckinDeposits',dateCheckin);
		$('#calendar_btw_checkoutDeposits').attr('dateofBtwCheckoutDeposits',dateCheckout);
	}
	// set for pager
	getCurrentTabData().tablePager = "tablepagingDeposits";
	getCurrentTabData().pagerNumberField = "pagerBookingDepositsListRoomManageMent";
	getCurrentTabData().functionGetData = "getReservationRoomBookingDepositsManageMent";
	getCurrentTabData().pageName = "BookingDepositsListRoomManageMent";
	getCurrentTabData().pageNavPosition = "pageNavPositionDeposits";
	getCurrentTabData().trCheck = "trDeposits";
	if(getCurrentTabData().checkinDeposits!=undefined){
		$('#calendar_btw_checkinDeposits').val($.datepicker.parseDate("yy-mm-dd",getCurrentTabData().checkinDeposits).getFormatedString());
		$('#calendar_btw_checkinDeposits').attr('dateofBtwCheckinDeposits',getCurrentTabData().checkinDeposits);
	}
	if(getCurrentTabData().checkoutDeposits!=undefined){
		$('#calendar_btw_checkoutDeposits').val($.datepicker.parseDate("yy-mm-dd",getCurrentTabData().checkoutDeposits).getFormatedString());
		$('#calendar_btw_checkoutDeposits').attr('dateofBtwCheckoutDeposits',getCurrentTabData().checkoutDeposits);
	}
	if(getCurrentTabData().typeReservationDeposits!=undefined){
		$('#typeCheckReservationDeposits option[value='+getCurrentTabData().typeReservationDeposits+']').attr('selected', 'selected');
	}
	if(data.trim()=="[]"){
		var textDataEmpty = '<tr clearTr="bookingdepositsReservation" >'+
		'<td colspan="100%" style="text-align:center;" >'+
		dataEmpty+
		'</td>'+
		'</tr>';
		textRoomBookingDeposits = textDataEmpty;
		$("[clearTr=bookingdepositsReservation]").remove();
		$("#BookingDepositsListRoomManageMent_Id_Tr").replaceWith("<tr id=BookingDepositsListRoomManageMent_Id_Tr ></tr>"+textRoomBookingDeposits);
		textRoomBookingDeposits = '';
	}else{
		$("[clearTr=bookingdepositsReservation]").remove();
		var objArray = new Array();
		if((data=="textSearch"||data=="G"||data=="S"||data=="A"||data=="reservationType_A"||data=="Checked-out Rooms"
			||data=="Checked-in Rooms")&&data!="dateSearch"
			||data=="Reserved Rooms"||data=="Checked-out Rooms"||data=="Checked-in Rooms"){
			objArray = oldObjArrayDeposits;
			objArray = objArray[0];
		}else{
			objArray = JSON.parse(data);
			oldObjArrayDeposits = objArray;
			objArray = objArray[0];
		}
		var numberSet = getCurrentTabData().beforePageDeposits; 
		var numberSubSet = getCurrentTabData().beforeSubPageDeposits;
		sortIdRoommanagement(objArray);
		textRoomBookingDepositsPrint = '';
		var checkBgColor = 0;
		var countGroup = 0;
		var OldGroupId =0;
		var valueSearch ="";
		var firstSelect ="";
		var typeReservation = $("#typeCheckReservationDeposits").val();
		var emailPic = '<img src=../images/components/roommanagement/email.png alt=Note height=15 width=20>';
		var printPci = '<img src=../images/components/roommanagement/print.png alt=Note height=15 width=20>';
		for(var i =0;i<objArray.length;i++){
			if(objArray[i].name!=""&&objArray[i].name!=undefined){
				var nameReservation = objArray[i].name.split(" ");
			}else{
				var nameReservation = "";
			}
			var Objtitle = objArray[i].reservationTitle;
			var ObjgroupId = objArray[i].groupId;
			var ObjId = objArray[i].id;
			
			var checkContinue = checkedFilter(output,valueSearch,nameReservation,firstSelect,Objtitle,ObjgroupId,typeReservation,ObjId)
			if(checkContinue==1){
				continue;
			}
			if(objArray[i].groupId!="0"){
				if(objArray[i].subList!=undefined){
					//OldGroupId = objArray[i].groupIdString;
					var setDateFormat = new Date(objArray[i].date);
					var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
					groupId = objArray[i].groupIdString;
					var splitResIdInGroup = objArray[i].resList.split(",");
					var textSubRes = "";
					var textSubResPrint = "";
					var checkBgColorG =0;
					var StatusResInGroup = "";
					for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
						var setDateFormatRes = new Date(objArray[i].subList[subRes].date);
						var setFateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].subList[subRes].span);
						var ShowNameGuest = "";
						/// Name Empty
						if(objArray[i].subList[subRes].name!=undefined){
							ShowNameGuest = objArray[i].subList[subRes].name
						}
						///
						if(objArray[i].subList[subRes].reservationTitle=="Reserved Rooms"){
							StatusResInGroup = statusResv;
						}else if(objArray[i].subList[subRes].reservationTitle=="Checked-out Rooms"){
							StatusResInGroup = statusCheckOut;
						}else if(objArray[i].subList[subRes].reservationTitle=="Temp Rooms"){
							StatusResInGroup = statusTempResv;
						}else if(objArray[i].subList[subRes].reservationTitle=="Cancel Reservation"){
							StatusResInGroup = statusCancelCheckin;
						}else{
							StatusResInGroup = statusCheckin;
						}
						if(checkBgColorG==0){
							statusRecord = 'dataRecordBot';
							checkBgColorG = 1;
						}else{
							statusRecord = 'dataRecordBot';
							checkBgColorG =0;
						}
						var showDisplayGuestname = "";
						if(ShowNameGuest==""){
							showDisplayGuestname = '<tr clearTr=bookingdepositsReservation class="'+statusRecord+'" onclick="if(linkClick==true)noGuestName();"  id="btnEditS" >';
						}else{
							showDisplayGuestname = '<tr clearTr=bookingdepositsReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >';
						}
						var runnumberSub = "";
						if(getCurrentTabData().beforePageDeposits!=undefined&&getCurrentTabData().beforePageDeposits!=""){
							runnumberSub = (numberSet+1)+"."+(subRes+1);
						}else{
							runnumberSub = (i+1)+"."+(subRes+1);
						}
							textSubRes += showDisplayGuestname+
							'<td class="spanDataRight">'+
							runnumberSub+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+objArray[i].subList[subRes].id+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">' +
							
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span class="guestName" >'+ShowNameGuest+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].subList[subRes].span+'</span>'+
							'</td>'+
							'<td class="spanDataCenter"> '+
								'<span>'+toCurrencyString((objArray[i].subList[subRes].defaultCherge))+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+toCurrencyString((objArray[i].subList[subRes].paymentAmount))+'</span>'+
							'</td>'+
							'</tr>';
							
							textSubResPrint += '<tr clearTr="bookingdepositsReservation" class="dataRecord" onclick="if(linkClick&&ShowNameGuest!="") CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >'+
							'<td class="spanDataRight">'+
							runnumberSub+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+objArray[i].subList[subRes].id+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">' +
							
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span class="guestName" >'+ShowNameGuest+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].subList[subRes].span+'</span>'+
							'</td>'+
							'<td class="spanDataCenter"> '+
								'<span>'+toCurrencyString((objArray[i].subList[subRes].defaultCherge))+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+toCurrencyString((objArray[i].subList[subRes].paymentAmount))+'</span>'+
							'</td>'+
							'</tr>';
						
					}
					///Check StatusGroup
					var obj = objArray[i].subList;
					showStatusResInGroup = checkStatusReservationGroup(obj);
					///
						if(getCurrentTabData().beforePageDeposits!=undefined&&getCurrentTabData().beforePageDeposits!=""){
							numberSet = numberSet+1;
							number = numberSet;
						}else{
							number = (i+1);
						}
						textRoomBookingDeposits += '<tr clearTr=bookingdepositsReservation class="dataRecordGroup" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].groupIdString+')"  id="btnEditG" >'+
						'<td class="spanDataCenter">'+
						number+'(<span id=groupCount'+objArray[i].groupIdString+' >'+objArray[i].resList.split(",").length+'</span>)'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>G'+objArray[i].groupIdString+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="ownerName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
						'</td>'+
						'<td class="spanDataCenter">'+
						toCurrencyString(objArray[i].paymentAmount)+
						'</td>'+
					'</tr>'+textSubRes;
						textRoomBookingDepositsPrint += '<tr clearTr=bookingdepositsReservation class="dataRecordGroup" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].groupIdString+')"  id="btnEditG" >'+
						'<td class="spanDataCenter">'+
						number+'(<span id=groupCount'+objArray[i].groupIdString+' >'+objArray[i].resList.split(",").length+'</span>)'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>G'+objArray[i].groupIdString+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="ownerName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
						'</td>'+
						'<td class="spanDataCenter">'+
							toCurrencyString(objArray[i].paymentAmount)+
						'</td>'+
					'</tr>'+textSubResPrint;
				}else{
					var setDateFormatRes = new Date(objArray[i].date);
					var setFateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].span);
					var ShowNameGuest = "";
					/// Name Empty
					if(objArray[i].name!=undefined){
						ShowNameGuest = objArray[i].name
					}
					///
					if(objArray[i].reservationTitle=="Reserved Rooms"){
						StatusResInGroup = statusResv;
					}else if(objArray[i].reservationTitle=="Checked-out Rooms"){
						StatusResInGroup = statusCheckOut;
					}else if(objArray[i].reservationTitle=="Temp Rooms"){
						StatusResInGroup = statusTempResv;
					}else if(objArray[i].reservationTitle=="Cancel Reservation"){
						StatusResInGroup = statusCancelCheckin;
					}else{
						StatusResInGroup = statusCheckin;
					}
					if(checkBgColorG==0){
						statusRecord = 'dataRecordBot';
						checkBgColorG = 1;
					}else{
						statusRecord = 'dataRecordBot';
						checkBgColorG =0;
					}
					var showDisplayGuestname = "";
					if(ShowNameGuest==""){
						showDisplayGuestname = '<tr clearTr=bookingdepositsReservation class="'+statusRecord+'"   id="btnEditS" >';
					}else{
						showDisplayGuestname = '<tr clearTr=bookingdepositsReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >';
					}
					var runnumberSub = "";
					if(getCurrentTabData().beforePageDeposits!=undefined&&getCurrentTabData().beforePageDeposits!=""){
						runnumberSub = (numberSet)+"."+(numberSubSet);
						numberSubSet = numberSubSet+1;
					}else{
						runnumberSub = (i+1)+"."+(subRes+1);
					}
					
					textRoomBookingDeposits += showDisplayGuestname+
						'<td class="spanDataRight">'+
						runnumberSub+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
						
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+ShowNameGuest+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+toCurrencyString((objArray[i].paymentAmount))+'</span>'+
						'</td>'+
						'</tr>';
						
					textRoomBookingDepositsPrint += '<tr clearTr="bookingdepositsReservation" class="dataRecord" onclick="if(linkClick&&ShowNameGuest!="") CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >'+
						'<td class="spanDataRight">'+
						runnumberSub+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
						
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+ShowNameGuest+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+toCurrencyString((objArray[i].paymentAmount))+'</span>'+
						'</td>'+
						'</tr>';
				}
			}else{
				res = objArray[i].id;
				var sourcesString = "";
				var setDateFormat = new Date(objArray[i].date);
				var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
				getStatusResInGroup = objArray[i].reservationTitle;
				if(getStatusResInGroup=="Reserved Rooms"){
					showStatusResInGroup = statusResv;
				}else if(getStatusResInGroup=="Checked-out Rooms"){
					showStatusResInGroup = statusCheckOut;
				}else if(getStatusResInGroup=="Temp Rooms"){
					showStatusResInGroup = statusTempResv;
				}else if(getStatusResInGroup=="Cancel Reservation"){
					showStatusResInGroup = statusCancelCheckin;
				}else{
					showStatusResInGroup = statusCheckin;
				}
				if(objArray[i].sourcesString){
					sourcesString =	objArray[i].sourcesString
				}
				if(checkBgColor==0){
					statusRecord = 'dataRecordBot';
					checkBgColor = 1;
				}else{
					statusRecord = 'dataRecordBot';
					checkBgColor =0;
				}
				if(getCurrentTabData().beforePageDeposits!=undefined&&getCurrentTabData().beforePageDeposits!=""){
					numberSet = numberSet+1;
					number = numberSet;
				}else{
					number = (i+1);
				}
				if(setDateFormat.getFormatedString()!=undefined){
						textRoomBookingDeposits += '<tr clearTr=bookingdepositsReservation class="'+statusRecord+'" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS">'+
						'<td class="spanDataCenter" >'+
						number+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
						'<span>'+sourcesString+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].paymentAmount))+'</span>'+
						'</td>'+
						'</tr>';
						textRoomBookingDepositsPrint += '<tr clearTr=bookingdepositsReservation class="dataRecord" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS">'+
						'<td class="spanDataCenter" >'+
						number+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
						'<span>'+sourcesString+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].paymentAmount))+'</span>'+
						'</td>'+
					'</tr>';
				}
			}
		}
		if(textRoomBookingDeposits==""){
			var textDataEmpty = '<tr clearTr="bookingdepositsReservation" >'+
			'<td colspan="100%" style="text-align:center;" >'+
			dataEmpty+
			'</td>'+
			'</tr>';
			textRoomBookingDeposits = textDataEmpty;
		}
		$("#BookingDepositsListRoomManageMent_Id_Tr").replaceWith("<tr id=BookingDepositsListRoomManageMent_Id_Tr ></tr>"+textRoomBookingDeposits);
		textRoomBookingDeposits = "";
		textSubRes = "";
		textPrint = textRoomBookingDepositsPrint;
	}
	dateRoomManageMent({checkin:"calendar_btw_checkinDeposits",atrcheckin:"dateofBtwCheckinDeposits"},{checkout:"calendar_btw_checkoutDeposits",atrcheckout:"dateofBtwCheckoutDeposits"});
	$(".ui-datepicker-trigger").css("margin-top","2px");
	closeWaitingDialog();
	showDataResRoomManageMentSetPageDeposits(data,getCurrentTabData().lineDeposits);
}

function showDataResRoomManageMentSetPageDeposits(data,output){
	$("[clearTr*=depositsReservationPage]").remove();
	objArray = JSON.parse(data);
	objArray = objArray[1];
	var textRoomDepositsSetpage = "";
	for(var i =0;i<objArray.length;i++){
		var textSubRes = "";
		if(objArray[i].groupId!="0"){
			var statusRecord = "";
			for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
				textSubRes += '<tr clearTr=depositsReservationPage  ><td></td></tr>';
			}
			textRoomDepositsSetpage += '<tr clearTr=depositsReservationPage class="trDeposits"><td></td></tr>'+textSubRes;
		}else{
			textRoomDepositsSetpage += '<tr clearTr=depositsReservationPage ><td></td></tr>';
		}
	}
	$("[name = BookingDepositsListRoomManageMent_Id_Tr2]").replaceWith("<tr name=BookingDepositsListRoomManageMent_Id_Tr2></tr>"+textRoomDepositsSetpage);
	textRoomDepositsSetpage = "";
	textSubRes = "";
	
	showPager(output);
}

function showDataResRoomManageMentSetCountDeposits(data,output){
	var subCount = 0;
	var recCount = 0;
	var objArray = new Array();
	if((data=="textSearch"||data=="G"||data=="S"||data=="A"||data=="reservationType_A"||data=="Checked-out Rooms"||data=="Checked-in Rooms")&&data!="dateSearch"){
		objArray = oldObjArrayDeposits;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}else{
		objArray = JSON.parse(data);
		oldObjArrayDeposits = objArray;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}
	setoldObjArrayDeposits = objArray;
	sortIdRoommanagement(objArray);
	sortIdRoommanagement(objArrayCheck);
	for(var i =0;i<objArray.length;i++){
		if(objArray[i].groupId!="0"){
			if(objArray[i].subList!=undefined){
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					if(objArrayCheck[objArrayCheck.length-1].subList!=undefined){
						subCount = objArrayCheck[objArrayCheck.length-1].subList.length+1;
					}
					break;
				}
			}else{
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					break;
				}
			}
		}else{
			if(objArrayCheck[objArrayCheck.length-1].id==objArray[i].id){
				recCount = (i+1);
				break;
			}
		}
	}
	getCurrentTabData().beforePageDeposits = (recCount);
	getCurrentTabData().beforeSubPageDeposits = subCount;
	simpleservice(getCurrentTabData().linkSet,null,showDataResRoomBookingDepositsManageMent,data);
}

function typeReservationDepositsFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName){
	var valueDateCheckin = getCurrentTabData().valueDateCheckin;
	var valueDateCheckout = getCurrentTabData().valueDateCheckout;
	if((valueDateCheckin!=""&&valueDateCheckout!="")&&(valueDateCheckin!=undefined&&valueDateCheckout!=undefined)){
		if(dataOld=="G"){
			getCurrentTabData().typeReservationDeposits = data;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationBookingDepositsGroup&offset="+offfset
				+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationBookingDepositsGroup&offset="+offfset
				+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
			}else{
				getCurrentTabData().beforePageDeposits = ""; 
				getCurrentTabData().beforeSubPageDeposits = "";
				var link = "/reservationService?func=getReservationBookingDepositsGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
			}
		}else if(dataOld=="S"){
			getCurrentTabData().typeReservationDeposits = data;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationBookingDepositsSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationBookingDepositsSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
			}else{
				getCurrentTabData().beforePageDeposits = ""; 
				getCurrentTabData().beforeSubPageDeposits = "";
				var link = "/reservationService?func=getReservationBookingDepositsSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
			}
		}else if(dataOld=="A"){
			getCurrentTabData().typeReservationDeposits = data;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationBookingDeposits&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationBookingDeposits&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
			}else{
				getCurrentTabData().beforePageDeposits = ""; 
				getCurrentTabData().beforeSubPageDeposits = "";
				var link = "/reservationService?func=getReservationBookingDeposits&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
			}
		}
	}else{
		if(dataOld=="G"){
			getCurrentTabData().typeReservationDeposits = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationBookingDepositsGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationBookingDepositsGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
			}else{
				getCurrentTabData().beforePageDeposits = ""; 
				getCurrentTabData().beforeSubPageDeposits = "";
				var link = "/reservationService?func=getReservationBookingDepositsGroup&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
			}
		}else if(dataOld=="S"){
			getCurrentTabData().typeReservationDeposits = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationBookingDepositsSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationBookingDepositsSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
			}else{
				getCurrentTabData().beforePageDeposits = ""; 
				getCurrentTabData().beforeSubPageDeposits = "";
				var link = "/reservationService?func=getReservationBookingDepositsSingle&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
			}
		}else if(dataOld=="A"){
			getCurrentTabData().typeReservationDeposits = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationBookingDeposits&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationBookingDeposits&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountDeposits,getCurrentTabData().lineDeposits);
			}else{
				getCurrentTabData().beforePageDeposits = ""; 
				getCurrentTabData().beforeSubPageDeposits = "";
				var link = "/reservationService?func=getReservationBookingDeposits&offset="
					+offfset+"&line="+getCurrentTabData().lineDeposits+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomBookingDepositsManageMent,data);
			}
		}
	}
}